home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 29 / CDT29.iso / e-Mail / WorldClient Pro 2.2.3 / wcsetup.exe / WEBHELP.ZIP / hhapplet / FTSPane.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-10-21  |  6.4 KB  |  298 lines

  1. package hhapplet;
  2.  
  3. import java.applet.Applet;
  4. import java.awt.BorderLayout;
  5. import java.awt.Button;
  6. import java.awt.Color;
  7. import java.awt.Component;
  8. import java.awt.Container;
  9. import java.awt.Event;
  10. import java.awt.Font;
  11. import java.awt.Label;
  12. import java.awt.LayoutManager;
  13. import java.awt.List;
  14. import java.awt.Panel;
  15. import java.awt.TextField;
  16. import java.net.MalformedURLException;
  17. import java.net.URL;
  18.  
  19. public class FTSPane extends Panel implements DialogDoneTarget {
  20.    protected Applet m_applet;
  21.    protected List m_list;
  22.    protected List m_listHolder;
  23.    protected SearchTree m_forapplelistHolder;
  24.    protected SearchTree m_forapplelist;
  25.    protected TextField m_tfEdit = new TextField();
  26.    protected FTSNorthPanel m_pnlNorth = new FTSNorthPanel(this);
  27.    protected Button m_btnDisplay = new Button("Display");
  28.    protected Button m_btnFind = new Button("Find");
  29.    protected IndexSecondaryDialog m_dlgSecondary;
  30.    protected int m_nSelectedIndex = -1;
  31.    protected FTSSearcher m_ftsSearcher = null;
  32.    protected Panel m_pnlEditArea = new Panel();
  33.    protected Label m_lblEditArea = new Label("Type in the word(s) to search for:");
  34.    protected LayoutManager m_layEditArea = new BorderLayout(0, 0);
  35.    protected boolean m_bIsIE4 = false;
  36.    protected boolean m_bIsNSWin16 = false;
  37.    protected boolean m_bIsNSWin32 = false;
  38.    protected boolean m_bIsIE3 = false;
  39.    protected boolean m_bUseForAppleList = false;
  40.    private LayoutManager m_layout;
  41.  
  42.    public boolean gotFocus(Event var1, Object var2) {
  43.       if (var1.target != this.m_tfEdit && var1.target != this.m_list && var1.target != this.m_forapplelist && var1.target != this.m_btnDisplay && var1.target != this.m_btnFind) {
  44.          this.m_tfEdit.requestFocus();
  45.       }
  46.  
  47.       return true;
  48.    }
  49.  
  50.    public void HideList() {
  51.       if (!this.m_bUseForAppleList) {
  52.          this.m_listHolder.clear();
  53.          this.m_listHolder.addItem("Searching...");
  54.          this.m_list.show(false);
  55.          ((Container)this).add("Center", this.m_listHolder);
  56.          this.m_listHolder.show(true);
  57.          ((Container)this).layout();
  58.          ((Component)this).paintAll(((Component)this).getGraphics());
  59.       }
  60.  
  61.       ((Container)this).paintComponents(((Component)this).getGraphics());
  62.    }
  63.  
  64.    public SearchTree getforappleList() {
  65.       return this.m_forapplelist;
  66.    }
  67.  
  68.    public void dialogDone() {
  69.       this.m_dlgSecondary = null;
  70.       this.m_tfEdit.requestFocus();
  71.    }
  72.  
  73.    public FTSPane(Applet var1, FTSSearcher var2) {
  74.       this.m_applet = var1;
  75.       this.m_ftsSearcher = var2;
  76.       this.m_layout = new BorderLayout(2, 2);
  77.       ((Container)this).setLayout(this.m_layout);
  78.  
  79.       try {
  80.          if (System.getProperty("java.vendor").startsWith("Netscape")) {
  81.             if (System.getProperty("os.name").startsWith("16-bit Windows")) {
  82.                this.m_bIsNSWin16 = true;
  83.             } else if (System.getProperty("os.name").startsWith("Windows")) {
  84.                this.m_bIsNSWin32 = true;
  85.             } else if (System.getProperty("os.name").startsWith("Mac")) {
  86.             }
  87.          } else if (System.getProperty("java.vendor").startsWith("Microsoft")) {
  88.             if (System.getProperty("java.version").startsWith("1.1")) {
  89.                this.m_bIsIE4 = true;
  90.             } else {
  91.                this.m_bIsIE3 = true;
  92.             }
  93.  
  94.             if (System.getProperty("os.name").startsWith("Mac")) {
  95.                this.m_bUseForAppleList = true;
  96.             }
  97.          }
  98.       } finally {
  99.          ;
  100.       }
  101.  
  102.       if (this.m_bUseForAppleList) {
  103.          this.m_forapplelistHolder = new SearchTree(this);
  104.          this.m_forapplelist = new SearchTree(this);
  105.       } else {
  106.          this.m_list = new List();
  107.          this.m_listHolder = new List();
  108.          this.m_list.setBackground(Color.white);
  109.       }
  110.  
  111.       int var3 = WebHelp.GetFontSize();
  112.       if (this.m_list != null) {
  113.          this.m_list.setFont(new Font(WebHelp.GetFontName(), 0, var3));
  114.       }
  115.  
  116.       this.m_tfEdit.setFont(new Font(WebHelp.GetFontName(), 0, var3));
  117.       this.m_btnDisplay.setFont(new Font(WebHelp.GetFontName(), 0, var3));
  118.       this.m_btnFind.setFont(new Font(WebHelp.GetFontName(), 0, var3));
  119.       this.m_pnlEditArea.setLayout(this.m_layEditArea);
  120.       this.m_pnlEditArea.add("North", this.m_lblEditArea);
  121.       this.m_pnlEditArea.add("Center", this.m_tfEdit);
  122.       if (this.m_bUseForAppleList) {
  123.          this.m_forapplelistHolder.addItem("Loading Search Data...");
  124.          this.m_forapplelist.addItem("Loading Search Data...");
  125.       } else {
  126.          this.m_listHolder.addItem("Loading Search Data...");
  127.          this.m_listHolder.setBackground(Color.white);
  128.       }
  129.  
  130.       this.m_pnlNorth.add("North", this.m_pnlEditArea);
  131.       this.m_pnlNorth.add("South", this.m_btnFind);
  132.       ((Container)this).add("North", this.m_pnlNorth);
  133.       if (this.m_bUseForAppleList) {
  134.          ((Container)this).add("Center", this.m_forapplelist);
  135.       } else {
  136.          ((Container)this).add("Center", this.m_listHolder);
  137.       }
  138.  
  139.       ((Container)this).add("South", this.m_btnDisplay);
  140.       this.m_tfEdit.requestFocus();
  141.    }
  142.  
  143.    public List getList() {
  144.       return this.m_list;
  145.    }
  146.  
  147.    public void ShowList() {
  148.       if (!this.m_bUseForAppleList) {
  149.          this.m_listHolder.show(false);
  150.          this.m_layout.removeLayoutComponent(this.m_listHolder);
  151.          ((Container)this).add("Center", this.m_list);
  152.          ((Container)this).add("South", this.m_btnDisplay);
  153.          this.m_list.show(true);
  154.          ((Container)this).layout();
  155.          ((Component)this).paintAll(((Component)this).getGraphics());
  156.       }
  157.  
  158.       ((Container)this).paintComponents(((Component)this).getGraphics());
  159.    }
  160.  
  161.    public TextField getEditBox() {
  162.       return this.m_tfEdit;
  163.    }
  164.  
  165.    public boolean keyUp(Event var1, int var2) {
  166.       if (this.m_bIsNSWin16) {
  167.          var2 &= 255;
  168.       }
  169.  
  170.       if ((this.m_bIsIE4 || this.m_bIsIE3 || this.m_bIsNSWin32) && var1.key == 10) {
  171.          if (System.getProperty("java.version").startsWith("1.1.5") && this.m_bIsNSWin32) {
  172.             return super.keyUp(var1, var2);
  173.          }
  174.  
  175.          if (System.getProperty("java.version").startsWith("1.0.2") && System.getProperty("java.vendor").startsWith("Microsoft")) {
  176.             return super.keyUp(var1, var2);
  177.          }
  178.  
  179.          if (System.getProperty("java.version").startsWith("1.02") && System.getProperty("java.vendor").startsWith("Netscape")) {
  180.             return super.keyUp(var1, var2);
  181.          }
  182.  
  183.          if (var1.target == this.m_forapplelist || var1.target == this.m_list || var1.target == this.m_tfEdit) {
  184.             this.action(var1, var1.target);
  185.             return true;
  186.          }
  187.       }
  188.  
  189.       boolean var3 = super.keyUp(var1, var2);
  190.       if (var2 >= 32 && var2 <= 126) {
  191.          try {
  192.             this.textChanged();
  193.             if (var1.target == this.m_tfEdit) {
  194.                this.m_tfEdit.requestFocus();
  195.             }
  196.          } finally {
  197.             ;
  198.          }
  199.       }
  200.  
  201.       return var3;
  202.    }
  203.  
  204.    protected void gotoSelectedIndex() {
  205.       if (this.m_bUseForAppleList) {
  206.          int var7 = this.m_forapplelist.getSelectedIndex();
  207.          if (var7 != -1) {
  208.             try {
  209.                String var8 = this.m_applet.getParameter("Frame");
  210.                String var9 = this.m_ftsSearcher.getTopicURL(this.m_forapplelist.getItem(var7));
  211.                if (var9 != null && var9.length() != 0) {
  212.                   URL var10 = URLFileHandler.makeURL(this.m_applet.getDocumentBase(), var9, "");
  213.                   if (var8 == null) {
  214.                      this.m_applet.getAppletContext().showDocument(var10, "_self");
  215.                   } else {
  216.                      this.m_applet.getAppletContext().showDocument(var10, var8);
  217.                   }
  218.                }
  219.             } catch (MalformedURLException var5) {
  220.             }
  221.          }
  222.       } else {
  223.          int var1 = this.m_list.getSelectedIndex();
  224.          if (var1 != -1) {
  225.             try {
  226.                String var2 = this.m_applet.getParameter("Frame");
  227.                String var3 = this.m_ftsSearcher.getTopicURL(this.m_list.getItem(var1));
  228.                if (var3 != null && var3.length() != 0) {
  229.                   URL var4 = URLFileHandler.makeURL(this.m_applet.getDocumentBase(), var3, "");
  230.                   if (var2 == null) {
  231.                      this.m_applet.getAppletContext().showDocument(var4, "_self");
  232.                   } else {
  233.                      this.m_applet.getAppletContext().showDocument(var4, var2);
  234.                   }
  235.                }
  236.             } catch (MalformedURLException var6) {
  237.             }
  238.          }
  239.       }
  240.    }
  241.  
  242.    protected void finalize() throws Throwable {
  243.       if (this.m_bUseForAppleList) {
  244.          this.m_forapplelist.clear();
  245.          this.m_forapplelist = null;
  246.       } else {
  247.          this.m_list.clear();
  248.          this.m_list = null;
  249.       }
  250.  
  251.       super.finalize();
  252.    }
  253.  
  254.    public boolean action(Event var1, Object var2) {
  255.       System.out.println("action(" + var1.toString() + ", " + var2.toString() + ")");
  256.       if (var1.target != this.m_btnFind && var1.target != this.m_tfEdit) {
  257.          this.gotoSelectedIndex();
  258.       } else {
  259.          if (this.m_bUseForAppleList) {
  260.             this.m_ftsSearcher.doSearch(this.m_tfEdit.getText(), (List)null, this.m_forapplelist);
  261.          } else {
  262.             this.m_ftsSearcher.doSearch(this.m_tfEdit.getText(), this.m_list, (SearchTree)null);
  263.          }
  264.  
  265.          ((Container)this).paintComponents(((Component)this).getGraphics());
  266.       }
  267.  
  268.       return true;
  269.    }
  270.  
  271.    public boolean handleEvent(Event var1) {
  272.       if (System.getProperty("java.version").equalsIgnoreCase("1.0.2") && System.getProperty("java.vendor").startsWith("Microsoft") && var1.id == 402 && var1.key == 10 && var1.target != this.m_tfEdit) {
  273.          this.action(var1, var1.target);
  274.          return true;
  275.       } else if (System.getProperty("java.version").equalsIgnoreCase("1.1.5") && this.m_bIsNSWin32 && var1.id == 402 && var1.key == 10 && var1.target != this.m_tfEdit) {
  276.          this.action(var1, var1.target);
  277.          return true;
  278.       } else if (this.m_bIsIE4 && var1.id == 1001 && var1.target == this.m_tfEdit) {
  279.          return true;
  280.       } else {
  281.          if (var1.target == this.m_list && var1.id == 701 && this.m_list.getSelectedIndex() != this.m_nSelectedIndex) {
  282.             String var2 = this.m_list.getSelectedItem();
  283.             String var3 = this.m_ftsSearcher.getTopicURL(this.m_list.getSelectedItem());
  284.             this.m_nSelectedIndex = this.m_list.getSelectedIndex();
  285.             if (var3 != null && var3.length() != 0 && var2 != null) {
  286.                this.m_applet.showStatus(var2);
  287.                this.m_list.requestFocus();
  288.             }
  289.          }
  290.  
  291.          return super.handleEvent(var1);
  292.       }
  293.    }
  294.  
  295.    public void textChanged() {
  296.    }
  297. }
  298.